﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MaxLeaf.Platform.DataContract;
using CommonsLib.DB;
using MaxLeaf.Platform.DALImplementation;
using MaxLeaf.Platform.Functions;
using CommonsLib.Utility;
using MaxLeaf.Platform.Commons;

namespace MaxLeaf.Platform.BLLImplementation
{
    public class imStoresReqHdrBLL:BaseBLL
    {
        


        public override string FinterIDFields
        {
            get
            {
                return string.Format("{0},{1}", "FInterID", (int)FinterIDType.StoresReq);
            }
        }
        public override string BillNoFields
        {
            get
            {
                return string.Format("{0},{1}", "OrdNo", (int)FinterIDType.StoresReq);
            }
        }

        internal double GetDepAmt(int intDepID, int intType)
        {
            double dblAmt = 0;
            using (DBAccess dbcon = DataFunc.GetDBAccessByDataModelType(typeof(imStoresReqHdrDataModel)))
            {
                dblAmt=((imStoresReqHdrDAL)this.CurrentDAL).GetMonthDepAmt(dbcon, intDepID);
            }

            if (intType == 1)
            {
                //余额
                dblAmt = new mDepartmentBLL().GetMonthAppliedAmt(intDepID) - dblAmt;
            }

            return dblAmt;
        }

        internal double GetCompanyAmt(int intCompanyID, int intType)
        {
            double dblAmt = 0;
            using (DBAccess dbcon = DataFunc.GetDBAccessByDataModelType(typeof(imStoresReqHdrDataModel)))
            {
                dblAmt = ((imStoresReqHdrDAL)this.CurrentDAL).GetMonthCompanyAmt(dbcon, intCompanyID);
            }
            if (intType == 1)
            {
                //余额
                dblAmt = new mCompanyBLL().GetMonthAppliedAmt(intCompanyID) - dblAmt;
            }

            return dblAmt;
        }
    }
}
